//
//  HRAudioPath.m
//  SmartCommunity
//
//  Created by Harvey Huang on 15/8/4.
//  Copyright (c) 2015年 Horizontal. All rights reserved.
//

#import "HRAudioPath.h"

static NSString * const kFolderName = @"chatVoices";

@implementation HRAudioPath

+ (NSString *)recordPathOrigin
{
    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
//
//    NSString *voiceDirectory = [docPath stringByAppendingPathComponent:kFolderName];
//    
//    if ( ![[NSFileManager defaultManager] fileExistsAtPath:voiceDirectory]) {
//        [[NSFileManager defaultManager] createDirectoryAtPath:voiceDirectory withIntermediateDirectories:YES attributes:nil error:NULL];
//    }
    NSString *voiceDirectory = docPath;
    NSString *originPath = [voiceDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%f.wav", [[NSDate date] timeIntervalSince1970]]];
    
    return originPath;
}

+ (NSString *)recordPathOriginToAMR
{
    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
//
//    NSString *voiceDirectory = [docPath stringByAppendingPathComponent:kFolderName];
//    
//    if ( ![[NSFileManager defaultManager] fileExistsAtPath:voiceDirectory]) {
//        [[NSFileManager defaultManager] createDirectoryAtPath:voiceDirectory withIntermediateDirectories:YES attributes:nil error:NULL];
//    }
    
    NSString *voiceDirectory = docPath;
    NSString *toAMRPath = [voiceDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%f.amr", [[NSDate date] timeIntervalSince1970]]];
    
    return toAMRPath;
}

+ (NSString *)recordPathAMRToWAV
{
    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
//
//    NSString *voiceDirectory = [docPath stringByAppendingPathComponent:kFolderName];
//    
//    if ( ![[NSFileManager defaultManager] fileExistsAtPath:voiceDirectory]) {
//        [[NSFileManager defaultManager] createDirectoryAtPath:voiceDirectory withIntermediateDirectories:YES attributes:nil error:NULL];
//    }
    NSString *voiceDirectory = docPath;
    
    NSString *filePath = [voiceDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%f.wav", [[NSDate date] timeIntervalSince1970]]];
    
    return filePath;
}

@end
